package Thwmas;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.TextField;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.SwingConstants;
import java.awt.Choice;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.EventListener;


@SuppressWarnings("serial")
public class ItemWindow extends JPanel {    
	
	private JComboBox category;
	private TextField name;
	private TextField starting_price;	
	private JLabel categorylabel;
	private JLabel namelabel;
	private JLabel starting_pricelabel;
	private JButton clearbutton;
	private JButton submitbutton;
	private TextField textfield;
	
	
	public ItemWindow() 
	{
        super (new GridLayout(10,2));        
        
        //labels,text fields,buttons etc 
        categorylabel = new JLabel("Category",SwingConstants.CENTER);
        add(categorylabel);
        final JComboBox category = new JComboBox(new String[]{
        		"-","Books","Music","Shoes"});
        add(category);
        
        //create empty areas between labels
        JTextArea textArea = new JTextArea();
        textArea.setEditable(false);        textArea.setOpaque(false);
        textArea.setBorder(BorderFactory.createEmptyBorder());
        add(textArea, BorderLayout.CENTER);
        JTextArea textArea2 = new JTextArea();
        textArea2.setEditable(false);        textArea2.setOpaque(false);
        textArea2.setBorder(BorderFactory.createEmptyBorder());
        add(textArea2, BorderLayout.CENTER);
        
        JTextArea textArea3 = new JTextArea();
        textArea3.setEditable(false);        textArea3.setOpaque(false);
        textArea3.setBorder(BorderFactory.createEmptyBorder());
        add(textArea3, BorderLayout.CENTER);
        JTextArea textArea4 = new JTextArea();
        textArea4.setEditable(false);        textArea4.setOpaque(false);
        textArea4.setBorder(BorderFactory.createEmptyBorder());
        add(textArea4, BorderLayout.CENTER);
        
        JTextArea textArea5 = new JTextArea();
        textArea5.setEditable(false);        textArea5.setOpaque(false);
        textArea5.setBorder(BorderFactory.createEmptyBorder());
        add(textArea5, BorderLayout.CENTER);
        JTextArea textArea6 = new JTextArea();
        textArea6.setEditable(false);        textArea6.setOpaque(false);
        textArea6.setBorder(BorderFactory.createEmptyBorder());
        add(textArea6, BorderLayout.CENTER);
        
        namelabel = new JLabel("Name",SwingConstants.CENTER);
        add(namelabel);	
        name = new TextField(25);		
        add(name);
        
      //empty area between labels
        JTextArea textArea7 = new JTextArea();  
        textArea7.setEditable(false);        textArea7.setOpaque(false);   
        textArea7.setBorder(BorderFactory.createEmptyBorder());
        add(textArea7, BorderLayout.CENTER);
        JTextArea textArea8 = new JTextArea();  
        textArea8.setEditable(false);        textArea8.setOpaque(false);   
        textArea8.setBorder(BorderFactory.createEmptyBorder());
        add(textArea8, BorderLayout.CENTER);
        
        starting_pricelabel = new JLabel("Start Price",SwingConstants.CENTER);
        add(starting_pricelabel);
        starting_price = new TextField(10);		
        add(starting_price);
        
      //empty area between labels
        JTextArea textArea9 = new JTextArea();  
        textArea9.setEditable(false);        textArea9.setOpaque(false);   
        textArea9.setBorder(BorderFactory.createEmptyBorder());
        add(textArea9, BorderLayout.CENTER);
        JTextArea textArea10 = new JTextArea();  
        textArea10.setEditable(false);        textArea10.setOpaque(false);   
        textArea10.setBorder(BorderFactory.createEmptyBorder());
        add(textArea10, BorderLayout.CENTER);
     
        clearbutton = new JButton("Clear");
        add(clearbutton);        
        clearbutton.addActionListener(new ActionListener(){
        	public void actionPerformed(ActionEvent e){			
				name.setText(null);
				starting_price.setText(null);				
				category.setSelectedIndex(0);
        	}
        });  
        
        submitbutton = new JButton("Submit");
        add(submitbutton);	
    } 

    /**
     * Create the GUI and show it.  For thread safety,
     * this method should be invoked from the event-dispatching thread.
     */	
    private static void createAndShowGUI() 
    {
        //Create and set up the window.
        JFrame frame = new JFrame("New Item");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        
        //Create and set up the content pane
        ItemWindow newContentPane = new ItemWindow();
        newContentPane.setOpaque(true); //content panes must be opaque
        frame.setContentPane(newContentPane);
        //Display the window
        frame.pack();
        frame.setVisible(true);
        frame.setResizable(false);
        frame.setLocation(550,350);
    }

    public static void main(String[] args) 
    {
        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }
}